home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
quartz
/
quartz10.lha
/
src
/
runtime
/
profile.h
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-29
|
4KB
|
156 lines
/* Global (and some not so global) profiling data structures */
#ifndef InitIdStackSize /* allow user to reset this */
#define InitIdStackSize 50
#endif
#define MaxProfilers (NUMPROCS/2)
#define bclear(p,t,n) bzero((char *)(p), (unsigned int)(sizeof(t) * (n)))
/* Status of synch vars */
#define ACTIVE 0
#define DISCARDED 1
typedef struct id_stack_entry {
unsigned int procID;
unsigned int returnPC;
} IdStackEntry;
typedef struct child_data {
unsigned int type;
BusyData busy;
int calleeID;
struct child_data *next;
} ChildData;
#define ChildTableInit(p,n) {\
int i; \
bclear(p,ChildData,n); \
for (i = 0; i < (n); i++) \
((p) + i)->type = ChildDataType; \
}
typedef struct concurrent_data {
unsigned int type;
int hit[MaxProfilers];
SpinLock lock;
BusyData busy;
NominalData nom;
ChildData kid;
} ConcurrentData;
#define ConDataTableInit(p,n) {\
int i; \
bclear(p,ConcurrentData,n); \
for (i = 0; i < (n); i++) { \
((p) + i)->type = ConcurrentDataType; \
((p) + i)->kid.type = ChildDataType; \
} \
}
typedef struct synch_samples {
ConcurrentData data;
QueueLength queue;
} SynchSamples;
#define SynchTableInit(p,n) {\
int i; \
bclear(p,SynchSamples,n); \
for (i = 0; i < (n); i++) { \
((p) + i)->data.type = ConcurrentDataType; \
((p) + i)->data.kid.type = ChildDataType; \
} \
}
typedef struct graph_entry {
int calleeID;
int callerID;
int num;
struct graph_entry *next; /* DONT MOVE */
} GraphEntry;
#define GraphEntryInit(p) bclear(p,GraphEntry,1)
#define GraphTableInit(p,n) bclear(p,GraphEntry,n)
typedef struct synch_profile
{
unsigned int type;
int status;
int kind;
struct thread *thread;
char *name; /* eg, the variable name */
int parentID; /* who initialized me */
struct synch_profile *next;
int number[NumNumbers];
GraphEntry g;
SpinLock graphLock;
/* used only by the dedicated processors */
usclk_t lastSample;
SynchSamples *samples;
struct synch_profile *dumpNext;
int synchId;
} SynchProfile;
#define AddNominal() AtomicIncr(nominalParallelism)
#define DecNominal() AtomicDecr(nominalParallelism)
#define NowBusy() AtomicIncr(effectiveParallelism)
#define NowIdle() AtomicDecr(effectiveParallelism)
#define PushOnIdStack(p,s) TPushOnIdStack(pP.thread,p,s)
#define PopOffIdStack() pP.thread->idStack.top--
#define TReplaceOnIdStack(t,p,s) ((t)->idStack.top->procID = ((int)(p)) | (s))
#define TSetState(t,s) ((t)->idStack.top->procID |= (s))
#define TClearState(t,s) ((t)->idStack.top->procID &= (s))
#define ReplaceOnIdStack(p,s) TReplaceOnIdStack(pP.thread,p,s)
#define TSetStateReady(t) TSetState(t,ReadyState)
#define SetStateSpin() TSetState(pP.thread,SpinState)
#define SetStateBlocked() TSetState(pP.thread,BlockedState)
#define SetStateBusy() TClearState(pP.thread,StateOffMask)
#define SetStateOverhead() TSetState(pP.thread,OverheadState)
#define SetStateNormal() TClearState(pP.thread,OverheadOffMask)
#define TSetStateNormal(t) TClearState(t,OverheadOffMask)
#define isSynchID(s) ((s) > mNumProcIds)
#define isOverhead(s) (((s) & OverheadState) || (s) == NoID)
#define isSpinning(s) (((s) & StateMask) == SpinState)
#define isBusy(s) (((s) & StateMask) == BusyState)
#define isBlocked(s) (((s) & StateMask) == BlockedState)
#define id2lock(p) \
(isSynchID(p) ? &((SynchProfile *)(p))->graphLock : &pcTableLocks[(p)])
#define SynchDispose(p) ((p)->status = DISCARDED)
/* communication between normal and dedicated processors */
extern private int profileOn;
extern shared int effectiveParallelism;
extern shared int nominalParallelism;
extern shared GraphEntry *pcTable;
extern shared int pcTableSize;
/* info passed into dump routines */
extern private int mNumProcIds;
extern shared FLOAT timeDiff;
extern shared int numSamples;
extern shared ConcurrentData *procData;
void TPushOnIdStack(), CallAndReplaceOnIdStack();
void ProfileInit(), ProfileStart(), ProcessorListInit(), ProfileSetAllBusy();
void ProfileExternal(), ProfileFinish();
void SynchpoolInit(), ProfileMustAdd(), DumpInfo();
int GetMyId();
SynchProfile *SynchInit();